//
//  String+Size.swift
//  OneDay
//
//  Created by cheng xi on 16/9/15.
//  Copyright © 2016年 xicheng. All rights reserved.
//

import UIKit

extension String {

    
    func sizeWithFont(_ font:UIFont) ->CGSize {
        return self.sizeWithFont(font, maxSize: CGSize(width: kMainScreenWidth, height: 40))
    }

    
    func sizeWithFont(_ font:UIFont,maxSize:CGSize) ->CGSize {
        let attrs = [NSFontAttributeName:font]
        
        return (self as NSString).boundingRect(with: maxSize, options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: attrs, context: nil).size
    }
    
}
